"""提交额度申请"""

from selenium.webdriver.common.by import By
from base.page_base import BasePage


class QuotaApplication(BasePage):
    """提交额度申请"""

    # 元素定位
    __loan_account_btn = By.PARTIAL_LINK_TEXT, '借款账户' # 借款账户按钮
    __quota_application_btn = By.LINK_TEXT, '申请额度' # 申请额度按钮
    __quota_application_text = By.ID, 'amount_account'# 申请额度文本
    __explanation_text = By.CLASS_NAME, 'lg-area' # 详细说明文本
    __verifycode_text = By.ID, 'verifycode' # 验证码文本
    __submit_btn = By.CLASS_NAME, 'btn-submit' # 确认提交按钮
    __assert_success_text = By.XPATH, '//span[text()="提交申请成功"]'

    def locan_account_click(self): # 点击借款账户按钮
        self.base_click(self.__loan_account_btn)

    def application_quota_click(self): # 点击申请额度按钮
        self.base_click(self.__quota_application_btn)

    def input_application_quota(self): # 输入申请额度
        self.base_input(self.__quota_application_text, '10000')

    def input_explanation(self):
        self.base_input(self.__explanation_text, '申请额度测试')

    def input_verifycode(self): # 输入验证码
        self.base_input(self.__verifycode_text, '8888')

    def submit_click(self): # 点击确认提交按钮
        self.base_click(self.__submit_btn)

    def assert_quota_application_success(self): # 断言申请额度成功
        return self.base_get_text(self.__assert_success_text)

    def quota_application_process(self): # 申请额度流程
        self.locan_account_click() # 点击借款账户按钮
        self.application_quota_click() # 点击申请额度按钮
        self.input_application_quota() # 输入申请额度
        self.input_explanation() # 输入详细说明
        self.input_verifycode() # 输入验证码
        self.submit_click() # 点击确认提交按钮
























